import { ref } from 'vue'
import { orderArchived } from '@/api/archived'

const useArchiveForm = () => {
  const form = ref({
    remark: '',
  })

  const submitLoading = ref(false)

  const submit = async (orderIds: Array<string>) => {
    submitLoading.value = true
    const res = await orderArchived({ remark: form.value.remark, workIds: orderIds })
    submitLoading.value = false
    return res.data as { code: number; success: boolean; message: string; data: object }
  }

  return {
    form,
    submitLoading,
    submit,
  }
}

export default useArchiveForm
